'''
  res.text 服务器返回Unicode编码的字符串，经过解码
  res.content 服务器返回的字节流数据bytes，直接拿到网络数据byte
    在网络中传输都是经过编码的byte，
  
'''

import requests

params = {'wd': '中国'}

headers = {
  'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
}

res = requests.get('https://www.baidu.com/s', params=params, headers=headers)

with open('python/pachong/baidu.html', 'w', encoding='utf-8') as fp:
  fp.write(res.content.decode('utf-8'))

print(res.url)

# print(type(res.text)) # 自己猜测Unicode
# print(res.text) # 中文乱码

# print(type(res.content)) # bytes
# print(res.content.decode('utf-8')) # 编码后的字符串，可以直接在网路传输

# print(res.url)
# print(res.encoding) # ISO-8859-1
# print(res.status_code)




